using System;
using System.Collections.Generic;
using System.Linq;

namespace Crap4Net
{
    public class ArgumentMatcher
    {
        private const int USERCLASS_GROUP = -1;

        string[][] argumentGroups = new string[][] { 
                new string[]{ "string", "String","System.String" }, 
                new string[]{ "int", "Int32","System.Int32", "int32" }, 
                new string[]{ "double", "float64","System.Double", "Double" }, 
                new string[]{ "float", "float32","System.Single", "Single" }, 
                new string[]{ "object", "Object","System.Object" }, 
                new string[]{ "bool", "boolean", "Boolean","System.Boolean" }, 
            };

        public bool IsMatching(string arg1, string arg2)
        {
            var group1 = Group(arg1);
            var group2 = Group(arg2);
            if ((group1 == USERCLASS_GROUP) || (group2 == USERCLASS_GROUP)) //user classes
                return arg1 == arg2;
            else
                return group1 == group2;
        }

        private int Group(string arg)
        {
            for (int i = 0; i < argumentGroups.Length; i++)
            {
                if (argumentGroups[i].Contains(arg))
                    return i;
            }
            return -1;
        }
    }
}
